package org.ttitfly.ttcore.displaytag;

import org.apache.commons.beanutils.PropertyUtils;
import org.displaytag.decorator.TableDecorator;

public class ItemLineCanCancelDecorator extends TableDecorator {

    public String getItemLineCol() {
        Object rowObject = this.getCurrentRowObject();
        Long id;
        boolean canCancel = false;
        try {
            id = (Long) PropertyUtils.getProperty(rowObject, "id");
            canCancel = ((Boolean) PropertyUtils.getProperty(rowObject, "canCancel")).booleanValue();
        } catch (Exception e) {
            id = new Long(-1);
        }

        if (canCancel) {
            return "<input type='checkbox'name='checkboxList' value='" + id + "' onclick='selfOnclick();'/>";
        } else {
            return " ";
        }

    }

    @Override
    public String addRowId() {

        String rowNumber = this.tableModel.getId() + "_" + this.getListIndex();

        return rowNumber + "\" onclick=\"true\" ondblclick=\"true";
    }

}
